package com.sino.business.service;

import java.util.Iterator;
import java.util.List;

import com.sino.bean.Basicinfo;
import com.sino.bean.Zlintro;
import com.sino.business.IZlIntroService;
import com.sino.dao.IBasicInfoDAO;
import com.sino.model.ZlIntroModel;

public class ZlIntroServiceImp implements IZlIntroService {
	private IBasicInfoDAO basicInfoDAO = null;
	/**
     * Description       	   ：保存专利奖励申报项目简介
     * @param zlintro     	   ：专利简介持久化对象
     */
	public void saveZlIntro(ZlIntroModel zlIntroModel){
		Zlintro zlintro = new Zlintro();
		zlintro.setBhqk(zlIntroModel.getBhqk());
		zlintro.setHjqk(zlIntroModel.getHjqk());
		zlintro.setJsqk(zlIntroModel.getJsqk());
		zlintro.setShqk(zlIntroModel.getShqk());
		zlintro.setZlid(zlIntroModel.getZlid());
		Zlintro temp = this.getBasicInfoDAO().findZjclClear(zlIntroModel.getZlid());
		if(temp == null){
			this.getBasicInfoDAO().saveZlIntro(zlintro);
		}else{
			this.getBasicInfoDAO().updateZlIntro(zlintro);
		}
	}
	/**
     * Description       	   ：更新专利奖励申报项目简介
     * @param zlintro     	   ：专利简介持久化对象
     */
	public void updateZlIntro(ZlIntroModel zlIntroModel){}
	/**
     * Description       	   ：根据专利Id查找专利申报简介信息
     * @param zlId	     	   ：专利id
     */
	public ZlIntroModel findZlintro(String zlId){
		List temp = this.getBasicInfoDAO().findZlintro(zlId);
		ZlIntroModel zlIntroModel = new ZlIntroModel();
		Iterator it = temp.iterator();
		Zlintro zlintro;
		Basicinfo basicinfo;
		while(it.hasNext()){
			zlintro = (Zlintro)it.next();
			basicinfo = zlintro.getBasicinfo(); 
			zlIntroModel.setBhqk(zlintro.getBhqk());
			zlIntroModel.setHjqk(zlintro.getHjqk());
			zlIntroModel.setJsqk(zlintro.getJsqk());
			zlIntroModel.setShqk(zlintro.getShqk());
			zlIntroModel.setZlid(zlintro.getZlid());
			
			zlIntroModel.setSbr(basicinfo.getSbr());
			zlIntroModel.setSbrLxdh(basicinfo.getSbrLxdh());
			zlIntroModel.setTjdwLxdh(basicinfo.getLxdh());
			zlIntroModel.setTjdwLxr(basicinfo.getLxr());
			zlIntroModel.setZlmc(basicinfo.getName());
			zlIntroModel.setZlid2(basicinfo.getZlid2());
			
			
			zlIntroModel.setQxkw(basicinfo.getQxkw().getName());
			zlIntroModel.setSqrq(com.sino.util.DateUtils.formatDateTime(basicinfo.getSqrq(),com.sino.util.DateUtils.FORMAT_DATE_YYYY_MM_DD));
			
			zlIntroModel.setNd(zlIntroModel.getSqrq().substring(0,4));
			zlIntroModel.setMonth(zlIntroModel.getSqrq().substring(5,7));
			zlIntroModel.setDay(zlIntroModel.getSqrq().substring(8,10));
		}
		return zlIntroModel;
	}
	//----------------------------------------接口
	public IBasicInfoDAO getBasicInfoDAO() {
		return basicInfoDAO;
	}
	public void setBasicInfoDAO(IBasicInfoDAO basicInfoDAO) {
		this.basicInfoDAO = basicInfoDAO;
	}
	
	
}
